package com.jqkb.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class ScreenReceiver extends BroadcastReceiver {
    public ScreenReceiver() {

    }

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(NewMessageService.TAG, "屏幕监听");
//        Toast.makeText(context, intent.getAction(), Toast.LENGTH_SHORT).show();
        if (Intent.ACTION_USER_PRESENT.equals(intent.getAction()) ||
                Intent.ACTION_USER_UNLOCKED.equals(intent.getAction()) ||
                Intent.ACTION_SCREEN_ON.equals(intent.getAction()) ||
                Intent.ACTION_SCREEN_OFF.equals(intent.getAction()) ||
                ScreenReceiver.class.getName().equals(intent.getAction())
                ) {
            Intent serviceIntent = new Intent(context, NewMessageService.class);
            //刷新服务
            context.startService(serviceIntent);
        }
    }
}
